package edu.ihs.lhpy.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import edu.ihs.lhpy.base.BaseAction;
import edu.ihs.lhpy.domain.BaseInfo;
@Controller
@Scope("prototype")
public class BaseInfoAction extends BaseAction<BaseInfo>{
	
	/**奖助体系*/
	public String award() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("award");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	
	/**联系方式*/
	public String contact() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("contact");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	
	/**联合培养简介*/
	public String joinIntroduce() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("joinIntroduce");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	
	/**培养方案*/
	public String trainPlan() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("trainPlan");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	
	/**学位授予*/
	public String degreeGrant() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("degreeGrant");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	
	/**工作流程*/
	public String workFlow() throws Exception{
		//准备回显数据
		BaseInfo baseInfo = baseInfoService.getByType("workFlow");
		ActionContext.getContext().getValueStack().push(baseInfo);
		return "editUI";
	}
	public String edit() throws Exception{
		BaseInfo baseInfo = baseInfoService.getById(model.getId());
		baseInfo.setAuthor(model.getAuthor());
		baseInfo.setContent(model.getContent());
		baseInfo.setTime(model.getTime());
		baseInfo.setTitle(model.getTitle());
		//更新到数据库中
		baseInfoService.update(baseInfo);
		return "editUI";
	}
}
